#include "tabooExpire.h"
#include "main-tools.h"
#include <stdio.h>
#include <stdlib.h>

PtabooExpire initTabooExpire(int tenure, TabooExpire now){
	PtabooExpire result = (PtabooExpire)malloc(sizeof(TabooExpire));
	checkMalloc(result,"taboo.c:initTaboo:1");
	*result = (TabooExpire)(now+tenure);
	return result;
}

void freeTabooExpire(PtabooExpire t){
	free(t);
}

void printTabooExpire(FILE* f, PtabooExpire t){
	fprintf(f,"%lu",*t);
}

bool isTaboo(PtabooExpire t, TabooExpire now){
	return getTenure(t, now);
}

int getTenure(PtabooExpire t, TabooExpire now){
	int tenure = (int)*t - (int)now;
	return tenure*(tenure>0);
}
